UBOUND Function Action Returns the upper bound (largest available subscript) for the indicated dimension of an array. Syntax UBOUND( array , dimension%) Remarks The UBOUND function is used with the LBOUND function to determine the size of an array. UBOUND takes the following arguments. ----------------------------------------------------------------------------- Argument Description ---------------------------------------------------------------------------- array The name of the array variable to Argument Description ---------------------------------------------------------------------------- array The name of the array variable to be tested. dimension% An integer ranging from 1 to the number of dimensions in array; indicates which dimension's upper bound is returned. Use 1 for the first dimension, 2 for the second dimension, and so on. This argument is optional for one-dimensional arrays. UBOUND returns the values listed below for an array with the following dimensions. DIM A(1 TO 100, 1 TO 3, -3 TO 4) ----------------------------------------------------------------------------- Invocation Value returned ---------------------------------------------------------------------------- UBOUND(A,1) 100 UBOUND(A,2) 3 UBOUND(A,3) 4 You can use the shortened syntax UBOUND( array) for one-dimensional arrays because the default value for dimension% is 1. Use the LBOUND function to find the lower limit of an array dimension. See Also DIM, LBOUND, OPTION BASE Example The following example shows how LBOUND and UBOUND can be used together in a SUB procedure to determine the size of an array passed to the procedure by a calling program. DECLARE SUB PRNTMAT (A!()) DIM A(0 TO 3, 0 TO 3) FOR I% = 0 TO 3 FOR J% = 0 TO 3 A(I%, J%) = I% + J% NEXT J% NEXT I% CALL PRNTMAT(A()) END SUB PRNTMAT (A()) STATIC FOR I% = LBOUND(A, 1) TO UBOUND(A, 1) FOR J% = LBOUND(A, 2) TO UBOUND(A, 2) PRINT A(I%, J%); " "; NEXT J% PRINT . PRINT NEXT I% END SUB